<?php

/**
 * Description of Application_Model_Utilitarios_Recurso
 *
 * @author Jean Brito
 */
class Application_Model_Utilitarios_Recurso extends Application_Model_Fix {

    protected $_table = 'utilitario_Recurso';
    protected $_fields = Array(
        'id' => Array(
            'name' => 'id',
            'type' => 'identifier',
            'label' => 'Id',
        ),
        'nome' => Array(
            'name' => 'nome',
            'type' => 'name',
            'label' => 'Nome',
        ),
        'title' => Array(
            'name' => 'title',
            'type' => 'text',
            'label' => 'Titulo',
        ),
        'model' => Array(
            'name' => 'model',
            'type' => 'text',
            'label' => 'Modelo',
        ),
        'view' => Array(
            'name' => 'view',
            'type' => 'text',
            'label' => 'Display',
        ),
    );
    protected $_data = Array(
        Array(
            'id' => 1,
            'nome' => 'Usuarios',
            'title' => 'Controle de usuarios',
            'model' => 'Utilitarios_Usuario',
            'view' => 'List',
        ),
        Array(
            'id' => 2,
            'nome' => 'Recursos',
            'title' => 'Controle de recursos',
            'model' => 'Utilitarios_Recurso',
            'view' => 'List',
        ),
        Array(
            'id' => 3,
            'nome' => 'Banco/Caixa',
            'title' => 'Controle de Bancos e Caixas',
            'model' => 'Administrativo_Banco',
            'view' => 'List',
        )
    );

    public function getActions(&$model) {
        $modelName = 'Application_Model_' . $model['model'];
        $modelInstance = new $modelName();
        $view = $modelInstance->getView($model['view']);

        $model['views'][$model['view']] = new Zend_Json_Expr("function(config,model){" .
                        "config['title']='".$model['title']."';".
                        "return Ext.create('AgenteNET.Index.Store.Model." . $model['model'] . ".Data').views['".$model['view']."'](config,model);" .
                        "}");
        return $model;
    }

}
